<?php

namespace App\Http\Requests;

use App\Http\Requests\Request;

class AdminfriendUpdateRequest extends Request
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'friend_name' => 'required',
            'friend_url' => array('regex:/(http?|ftp?):\/\/(www)\.([^\.\/]+)\.(com|cn)(\/[\w-\.\/\?\%\&\=]*)?/i'),
            'friend_logo' => 'image',
        ];
    }
    /*
        用户显示字段验证的错误信息
    */
    public function messages()
    {
        return [
            'friend_name.required' => '友链名称必须填写',
            'friend_url.regex' => '链接格式不正确,正确格式为http://www.***.com或者http://www.***.cn',
            'friend_logo.image' => '上传的logo格式必须是 jpeg、png、bmp、gif、或 svg'
        ];
    }
}
